<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="./layui/css/layui.css">
</head>
<body>
<script src="./layui/layui.all.js"></script>
<h1>test</h1>
<div>
    <label >附件上传</label>
    <button type="button" id="shangchuan">
       上传文件
    </button>
</div>
<div>
    <button type="button" id="model">
        测试
    </button>
</div>
</body>
<script>
    //一般直接写在一个js文件中
    layui.use(['layer', 'form','upload'], function(){
        var layer = layui.layer;
        var upload = layui.upload;
        var $ = layui.jquery;
        upload.render({
                 elem: '#shangchuan'
                 ,url: '/dm/api/upload/m/1/1/1/1/1/1'
                 ,accept: 'file' //普通文件
                ,multiple: true,
                choose: function(obj) {
                    console.log("111")
                    var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                    files=null;
                }
                 ,done: function(res){
                     layer.msg('上传成功');
                     console.log(res);
                 }
             });
        $('#model').click(function () {
            $.ajax({
                url: '/dm/api/modeltoPDF/1/1/1/1/1',
                dataType: 'text', //服务器返回json格式数据
                contentType: "application/json; charset=utf-8",
                type: 'post', //HTTP请求类型
                timeout: 1000, //超时时间设置为1秒；
                success: function(data) {
                    layer.msg('成功');
                }
            })
        });
    });

    </script>
</html>